package com.j2eefast.bussiness.contract.service;


import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.j2eefast.bussiness.contract.entity.BusArchivesEntity;
import com.j2eefast.bussiness.contract.entity.BusEquipmentRecordsEntity;
import com.j2eefast.bussiness.contract.entity.BusStandardListEntity;
import com.j2eefast.bussiness.contract.mapper.BusArchivesMapper;
import com.j2eefast.bussiness.contract.mapper.BusStandardListMapper;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.framework.annotation.DataFilter;
import com.j2eefast.framework.sys.entity.SysUserEntity;
import com.j2eefast.framework.utils.Constant;
import com.j2eefast.framework.utils.UserUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;


/**
 * <p>设备规范列表</p>
 *
 * @author: summer
 * @date: 2021-06-08 14:41
 * @web: http://www.letukeji.cn
 * @version: 1.0.1
 */

@Service
public class BusStandardListService extends ServiceImpl<BusStandardListMapper, BusStandardListEntity> {

    @Resource
    protected BusStandardListMapper busStandardListMapper;



//    /**
//     * 页面分页查询
//     */
//    public PageUtil findPage(Map<String, Object> params) {
//        QueryWrapper<BusStandardListEntity> r = new QueryWrapper<BusStandardListEntity>();
//        Page<BusStandardListEntity> page = this.baseMapper.selectPage(new Query<BusStandardListEntity>(params).getPage(), r);
//        return new PageUtil(page);
//    }

    /**
     * 页面分页查询
     */
    public PageUtil findPage(Map<String, Object> params) {
        String standardType = (String) params.get("standardType");
        String name = (String) params.get("name");
        String beginTime = (String) params.get("beginTime");
        String endTime = (String) params.get("endTime");
        Page<BusStandardListEntity> page = busStandardListMapper.findPage(
                new Query<BusEquipmentRecordsEntity>(params).getPage(),
                StrUtil.nullToDefault(standardType, ""),
                StrUtil.nullToDefault(name, ""),
                StrUtil.nullToDefault(beginTime, ""),
                StrUtil.nullToDefault(endTime, ""),
                (String) params.get(Constant.SQL_FILTER));
        return new PageUtil(page);
    }




//    /**
//     * 页面展示查询翻页
//     */
//    public PageUtil findPage(Map<String, Object> params) {
//
//		//String parentId = (String) params.get("parentId");
//        Page<BusScrapEntity> page = busScrapMapper.findPage(
//                new Query<BusDepreciationEntity>(params).getPage(),
//				//StrUtil.nullToDefault(parentId,""),
//                (String) params.get(Constant.SQL_FILTER));
//        return new PageUtil(page);
//    }

    public boolean deleteByIds(Long[] ids) {

        return busStandardListMapper.deleteByIds(ids);

    }

    public boolean updateCheck(Long id) {
        Long userId= UserUtils.getUserInfo().getId();

        return busStandardListMapper.updateCheck(id ,userId);

    }


    @DataFilter(compAlias="c",deptAlias = "d",userAlias = "u")
    public List<BusStandardListEntity> findList(Map<String, Object> params) {
//        String name = (String) params.get("name");
//        String ceoName = (String) params.get("ceoName");
//        String paymentNuit = (String) params.get("paymentNuit");
//        String contractSum = (String) params.get("contractSum");
//        String projectName = (String) params.get("projectName");
        Long[] ids  = (Long[]) params.get("ids");
        return busStandardListMapper.findList(
//                StrUtil.nullToDefault(name,""),
//                StrUtil.nullToDefault(ceoName,""),
//                StrUtil.nullToDefault(paymentNuit,""),
//                StrUtil.nullToDefault(projectName,""),
//                StrUtil.nullToDefault(contractSum,""),
                ids,
                (String) params.get(Constant.SQL_FILTER));
    }

//    public int getDepreciationInfo(String name){
//
//        BusDepreciationEntity b= busDepreciationMapper.getDepreciationInfo(name);
//        if(b!=null){
//            return 1;
//        }else
//            return 0;
//
//    }




}
